#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


# Web Exercise 1.3.24 - Quarterback rating
http://introcs.cs.princeton.edu/java/13flow/index.php#exercises

Syntax:
python qb_rating.py


Notes:
This could easily be adapted to allow inputting the static data.

Division updated in PEP 238 is better suited for this task, which is
imported using the __future__ module.

https://www.python.org/dev/peps/pep-0238
https://docs.python.org/2.7/library/__future__.html

'''

from __future__ import division


def main():
    ''' Calculate QB Rating for Steve Young's 1994 Season '''

    completed_passes = 324
    pass_attempts = 461
    passing_yards = 3969
    td_passes = 35
    interceptions = 10

    completion_ratio = (250/3) * ((completed_passes / pass_attempts) - 0.3)
    yds_per_pass = (25/6) * ((passing_yards / pass_attempts) -3)
    td_ratio = (1000/3) * (td_passes / pass_attempts)
    interception_ratio = (1250/3) * (.095 - (interceptions / pass_attempts))

    print 'QB Rating: {}'.format(completion_ratio + yds_per_pass +
                                 td_ratio + interception_ratio)


if __name__ == '__main__':
    main()
